﻿SELECT 
	MAX(EVENT_POSTED_DT)   POSTDATE
FROM
 	ENTERPRISE_RETAIL_VIEWS.VCCH205_SERVICE_ORDER_EVENT  
 WHERE
EXTRACT(MONTH FROM	EVENT_POSTED_DT) = EXTRACT(MONTH FROM	(DATE-1))
AND EXTRACT(YEAR FROM	EVENT_POSTED_DT) = EXTRACT(YEAR FROM (DATE-1))
AND DATA_SOURCE_CD IN (150)	
AND REPOSITORY_AFFILIATE_ACCT_ID > 0